import { createSlice, PayloadAction } from '@reduxjs/toolkit'

const initialState = {
	userInfo: {
		token: '',
		avator: '',
		nickname: '',
		hot: 0,
		quanzi: 0,
		about: 0,
		aboutd: 0
	}
}

type UserState = typeof initialState

const userSlice = createSlice({
	name: 'user',
	initialState,
	reducers: {
		loginSuccess(state, action: PayloadAction<UserState>) {
			state.userInfo = action.payload.userInfo
		}
	}
})

export const { loginSuccess } = userSlice.actions
export default userSlice